<?php

$doxtxt = $_GET['dox'];
//echo "dox is $doxtxt<br>";
//if($doxtxt =="Dvt") echo "yes<br>";
//else echo "no";
if($doxtxt=="Dvt"){
$oldfile = fopen("specialgrh1Dvt.php", "r") or exit("Unable to open file!");
$newfile = fopen("specialgrh1Dvt_name.php", 'w') or die("can't open file");
}

if($doxtxt=="Orig"){
$oldfile = fopen("specialgrh1Orig.php", "r") or exit("Unable to open file!");
$newfile = fopen("specialgrh1Orig_name.php", 'w') or die("can't open file");
}
if($doxtxt=="Ext"){
$oldfile = fopen("specialgrh1Ext.php", "r") or exit("Unable to open file!");
$newfile = fopen("specialgrh1Ext_name.php", 'w') or die("can't open file");
}


$newname = $_GET['newnametxt'];
//echo "new name is $newname<br>";


if($newname){

//Output a line of the file until the end is reached
  $tmp ="graph->title->Set(\"";

while(!feof($oldfile))
{	$line=fgets($oldfile);
  if(strpos($line,$tmp)){
	$Data="\$graph->title->Set('$newname');\n";
	fwrite($newfile, $Data);

  }
  else{
	$Data=$line;
		fwrite($newfile, $Data);

	//echo $line;
	
  }
}
fclose($oldfile);
fclose($newfile);
if($doxtxt=="Dvt")  $myFile = "./jpgraph_cache/specialgrh1Dvt_name.png";
else if($doxtxt=="Orig") $myFile = "./jpgraph_cache/specialgrh1Orig_name.png";
else $myFile = "./jpgraph_cache/specialgrh1Ext_name.png";
	if(file_exists($myFile)){
		unlink($myFile);
	}

	if($doxtxt=="Dvt"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt_name.php\">";
	echo "<br>
		<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt_name.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
	}
	else if($doxtxt=="Orig"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig_name.php\">";
	echo "<br>
		<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig_name.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
	}

	else if($doxtxt=="Ext"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext_name.php\">";
	echo "<br>
		<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext_name.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
	}


}//end of if newname not null
else{//newname is empty, do not change the name

	if($doxtxt=="Dvt"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
	echo "<br>
		<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
	}
	else if($doxtxt=="Orig"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">";
	echo "<br>
		<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
	}

	else if($doxtxt=="Ext"){
	echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
	echo "<br>
	<br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
}


}



?> 